package br.com.universidade.config;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class ConnectFactory {
	 public static Connection getConexao() {  
	        try {
	            String driverName = "com.mysql.jdbc.Driver";                       
	            Class.forName(driverName);
	            String serverName = "localhost:3306";  
	            String mydatabase = "universidadebd";   
	            String url = "jdbc:mysql://" + serverName + "/" + mydatabase;  
	            String username = "root";            
	            String password = "";    
	            Connection connection = DriverManager.getConnection(url, username, password); 
	            return connection;  
	        }  catch (ClassNotFoundException e) {  
	            System.out.println("O driver expecificado nao foi encontrado.");  
	            return null;  
	        } catch (SQLException e) {  
	            System.out.println("Nao foi possivel conectar ao Banco de Dados.");  
	            return null;  
	        }  
	 }
}
